home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_oth
/
m2path
/
pathfind.mod
< prev
next >
Wrap
Text File
|
1992-01-12
|
3KB
|
69 lines
(* Display current directory path.
Greg Vigneault, Jan.13.1992
Box 7169, Stn.A,
Toronto, Ontario,
Canada M5W 1X8.
greg.vigneault@canrem.uucp
gregsv@eastern.uucp
*)
MODULE PathFound; (* FST Modula-2 v2.0b *)
FROM stdio IMPORT WriteCard, WriteLn, WriteString;
FROM SYSTEM IMPORT ASSEMBLER;
TYPE String67 = ARRAY [0..67] OF CHAR; (* Path string type *)
VAR FoundPath : String67;
DosError : CARDINAL;
(*---------------------------------------*)
PROCEDURE CurrentPath( VAR PathStr : String67; VAR stat : CARDINAL );
BEGIN
ASM
LES SI, PathStr (* ptr to ARRAY *)
MOV DI,SI
XOR BX,BX (* cheap zero *)
XOR AL,AL (* another *)
MOV CX,67 (* str length *)
Strz: MOV ES:[SI+BX],AL (* zero out str *)
INC BX (* bump ptr *)
LOOP Strz (* zero all *)
MOV AH,19H (* get current drive *)
INT 21H (* via Dos *)
MOV DL,AL (* save for later Dos call *)
INC DL (* 1=A, 2=B... *)
ADD AL,65 (* make 0.. to 'A'.. *)
MOV ES:[SI],AL (* Drive letter into PathStr *)
INC SI
MOV BYTE ES:[SI],':' (* from root *)
INC SI
MOV BYTE ES:[SI],'\'
INC SI (* where Dos will load asciiz *)
PUSH DS (* save DS *)
MOV AX,ES (* to set to local *)
MOV DS,AX
MOV AX,4700H (* get current directory *)
INT 21H
POP DS (* restore M2 data seg *)
JC CPbye
XOR AX,AX (* all's well *)
CPbye: LES DI, stat
MOV ES:[DI],AX (* set status *)
END; (* asm *)
END CurrentPath;
(*---------------------------------------*)
BEGIN (*PathFound*)
WriteLn;
CurrentPath( FoundPath, DosError ); (* get current path *)
IF DosError = 0 (* no error *)
THEN
WriteString( "Current path is " );
WriteString( FoundPath )
ELSE
WriteString( "*** DOS error #" );
WriteCard( DosError, 2 );
END; (* if *)
WriteLn
END PathFound.